<script>
    $(function(){
        // $("[type=checkbox]:checked::parent").validationEngine();
        $('#form_id').validationEngine();
        $("input[name*='Time']").datepicker({dateFormat : 'yy-mm-dd'});
                
        $("[type='checkbox']").click(function()
        {
            var notNull='validate[required]';
            var isNumber='validate[required,custom[number]]';
            var isInteger='validate[required,custom[integer]]'; 
            var isDate='validate[required,custom[date]]';
            var notSet='hello world';
                    
            var  tmp=this.parentNode.parentNode;
            var cnt=tmp.getElementsByTagName('input');              
            if(this.checked)
            {                        
                for(i=3;i<=4;i++)
                {
                    cnt[i].className=notNull;                       
                }
                for(i=7;i<=9;i++)
                {
                    cnt[i].className=isNumber;                               
                }
                cnt[5].className=isDate;
                cnt[6].className=isInteger;
            }
            else
            {                      
                for(i=3;i<=9;i++)
                {
                    cnt[i].className=notSet;                       
                }                 
            }                                                         
        });
    });
</script>
<h3 id="comments-title">       <em>添加采购信息</em>       </h3>
<div class="comment-form">
    <div>      
        <?php
        echo form_open("order/order_wait_for_buy_add", array('id' => 'form_id'));
        ?>
        <table align="center" class="">
            <tr>
                <th>勾选</th>
                <th>商品编号</th>
                <th style="width:155px">图片</th>
                <th>销售链接</th>
                <th>颜色/尺码</th>
                <th>数量</th>
                <th>采购途径</th>
                <th>采购单号</th>
                <th>采购日期</th>
                <th>采购数量</th>
                <th>采购单价</th>
                <th>采购运费</th>
                <th>采购总额</th>
            </tr>
            <tbody>
                <?php
                foreach ($detail as $k => $v):
                    ?>
                    <tr class="tr_center">
                        <td>
                            <?php
                            $input_data = array(
                                "name" => "detail[checkbox][$k]",
                                "id" => "ids",
                                "value" => 0,
                                "checked" => 0,
                            );
                            echo form_checkbox($input_data);
                            ?>
                        </td>
                        <td>
                            <?php
                            echo $v['commodityNumber'];
                            ?>
                        </td>
                        <td>
                            <?php
                            echo $v['imagePath'];
                            ?>
                        </td>
                        <td>
                            <?php
                            echo $v['link'];
                            ?>
                        </td>
                        <td>
                            <?php
                            echo $v['colorAndSize'];
                            ?>
                        </td>
                        <td>
                            <?php
                            echo $v['amount'];
                            ?>
                        </td>
                        <td>
                            <input type="hidden" id="product_id"
                                   name="detail[commodityNumber][<?php echo $k; ?>]"
                                   value="<?php echo set_value("detail[commodityNumber][$k]", $v["commodityNumber"]); ?>" />
                            <input type="hidden" id="product_id"
                                   name="detail[id][<?php echo $k; ?>]"
                                   value="<?php echo set_value("detail[id][$k]", $v["id"]); ?>"/>
                                   <?php
                                   $data = array(
                                       "name" => "detail[procurement][$k]",
                                       "id" => "procurement",
                                       "value" => set_value("detail[procurement][$k]", $v['procurement']),
                                       "size" => "10",
                                   );
                                   echo form_input($data);
                                   ?>	         
                        </td>
                        <td>
                            <?php
                            $data = array(
                                "name" => "detail[procureNumber][$k]",
                                "id" => "procureNumber",
                                "value" => set_value("detail[procureNumber][$k]", $v['procureNumber']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	
                        </td>
                        <td>
                            <?php
                            $data = array(
                                "name" => "detail[procureTime][$k]",
                                "id" => "procureTime",
                                "value" => set_value("detail[procureTime][$k]", $v['procureTime']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	              
                        </td>
                        <td>                    
                            <?php
                            $data = array(
                                "name" => "detail[procureAmount][$k]",
                                "id" => "procureAmount",
                                "value" => set_value("detail[procureAmount[$k]", $v['procureAmount']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	
                        </td>
                        <td>
                            <?php
                            $data = array(
                                "name" => "detail[procureUnitPrice][$k]",
                                "id" => "procureUnitPrice",
                                "value" => set_value("detail[procureUnitPrice][$k]", $v['procureUnitPrice']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	                 
                        </td>
                        <td>
                            <?php
                            $data = array(
                                "name" => "detail[procureFreight][$k]",
                                "id" => "procureFreight",
                                "value" => set_value("detail[procureFreight][$k]", $v['procureFreight']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	                  
                        </td>
                        <td>
                            <?php
                            $data = array(
                                "name" => "detail[sum][$k]",
                                "id" => "sum",
                                "value" => set_value("detail[sum][$k]", $v['sum']),
                                "size" => "10",
                            );
                            echo form_input($data);
                            ?>	                  
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <center> 
            <?php
            echo form_submit('mysubmit', '保存');
            ?>
        </center>
        <?php
        echo form_close();
        ?>     
    </div>
</div>
<div class="clear"></div>
